﻿google.maps.event.addDomListener(window, 'load', function () {
    var places = new google.maps.places.Autocomplete(document.getElementById('srch-term'));


    var contactInfo = {};



    google.maps.event.addListener(places, 'place_changed', function () {
        var place = places.getPlace();
        var address = place.formatted_address;
        var latitude = place.geometry.location.D;
        var longitude = place.geometry.location.k;
        var city = place.vicinity;
        var mesg = "Address: " + address;
        mesg += "\nLatitude: " + latitude;
        mesg += "\nLongitude: " + longitude;
        mesg += "\nCity: " + city;
        alert(mesg);

        contactInfo = {
            City: city,
            Latitude: latitude,
            Longitude: longitude

        };
        debugger;

        passToController();
    });

    var passToController = function () {
        $.ajax({
            type: 'POST',
            data: contactInfo,
            url: '/Home/SubmitInfo',
            success: alert('Youhou'),
            error: alert('not good')
        });
    };
});